<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php echo $this->Html->charset(); ?>
        <title><?php echo $title_for_layout; ?></title>
        <?php
        echo $this->Html->meta('icon');
        echo $this->Html->css('jRating.jquery');
        echo $this->Html->css('bootstrap');
        echo $this->Html->css('jquery-ui-1.8.21.custom');
        echo $this->Html->css('style');

        echo $this->fetch('meta');
        echo $this->fetch('css');
        echo $this->fetch('script');

        //if(isset($fb_descripcion)) {
        //echo $this->Html->meta(array('property' => 'og:description', 'content' => $fb_descripcion)); 
        //}
        //if(isset($fb_titulo)) {
        //  echo $this->Html->meta(array('property' => 'og:title', 'content' => $fb_titulo)); 
        //}
        //if(isset($fb_imagen)) {
        //	echo $this->Html->meta(array('property' => 'og:image', 'content' => $this->Html->url('/' . 'img/' . $fb_imagen, true)));
        //}

        echo $this->Html->script('jquery-1.7.2.min');
        echo $this->Javascript->link('bootstrap');
        echo $this->Javascript->link('jRating.jquery');
        ?>
    </head>

    <body >

        <div class="container">
            <div id="header">
                <div class =' tituloslide'>
                    <?php
                    echo $this->Html->image("tituloPrincipal.jpg", array(
                        "alt" => "Corralon los mellizos",
                        'url' => array('controller' => 'pages', 'action' => 'display')
                    ));
                    ?>
                </div>
                <div class="navbar">
                    <div class="navbar-inner">
                        <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </a>
                        <div class="nav-collapse">
                            <ul class="nav">
                                <li>
                                    <?php echo $this->Html->link('Inicio', array('controller' => 'pages', 'action' => 'display')); ?>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">	Productos <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <?php echo $this->Html->link('Filtro1', array('controller' => 'viewProductos', 'action' => 'listProductos', 'todas')); ?>
                                        </li>
                                        <li>
                                            <?php echo $this->Html->link('Filtro2', array('controller' => 'viewProductos', 'action' => 'listProductos', 'todas')); ?>
                                        </li>
                                        <li>
                                            <?php echo $this->Html->link('Filtro3', array('controller' => 'viewProductos', 'action' => 'listProductos', 'todas')); ?>
                                        </li>
                                        <li>
                                            <?php echo $this->Html->link('SinFiltro', array('controller' => 'viewProductos', 'action' => 'listProductos', 'todas')); ?>
                                        </li>
                                    </ul>
                                </li>
                                <li>
                                    <?php echo $this->Html->link('Servicios', '#readmeModal', array('data-toggle' => 'modal')); ?>
                                </li>
                                <?php
                                if ($this->Session->read('Auth.User') == NULL) {
                                   // echo ("<li><a data-toggle='modal' href='#loginModal'>Iniciar sesi&oacute;n</a></li>");
                                } else {
                                    //echo "<li>" . $this->Html->link('Administrar', array('controller' => 'admin', 'action' => 'index')) . "</li>";
                                    //echo "<li>" . $this->Html->link('Salir', array('controller' => 'Users', 'action' => 'logout')) . "</li>";
                                }
                                ?>
                            </ul>
                            <?php
                            $url = $this->Html->url('/', true);
                            $url .= 'viewProductos/searchNombre'; //url de viewMovies/searchTitle
                            ?>
                            <form class="navbar-search pull-right" method="post" autocomplete = "off" action="<?php echo $url; ?>">
                                <div class="search-query" style="width:200px; height:30px; margin-top: -4px; padding: 3px 9px 2px;">
                                    <i class="icon-search icon-white" style="margin-top: 6px;"></i>
                                    <input id="typeahead" name="data[nombre]" type="text" class="search-query" data-provide="typeahead" placeholder="Buscar..." style="border:none; float:right; width:170px; margin: 1px 0 0 0; padding:4px" />
                                </div>
                            </form>
                            <?php
                            $url = $this->Html->url('/', true);
                            $url .= 'productosws/view.json'; //url del service web que obtiene las peliculas buscadas
                            ?>
                            <script type="text/javascript">
                                $(function() {

                                    $('#typeahead').typeahead({
                                        source: function(typeahead, query) {

                                            $.ajax({
                                                url: '<?php echo $url; ?>',
                                                type: 'GET',
                                                data: "query=" + query,
                                                dataType: 'JSON',
                                                async: false,
                                                success: function(data) {
                                                    typeahead.process(data);
                                                }
                                            });
                                        }
                                    });
                                });
                            </script>
                        </div>
                    </div>
                </div>
            </div>
            <div id="content">
                <?php echo $this->fetch('content'); ?>
            </div>

            <div id="footer">
                <br/><br/>
                Diseño de página <br/>
                Fabiani Luis <br/>
            </div>	

            <!-- cargo los js a lo ultimo para mejorar performance -->
            <?php
            echo $this->Javascript->link('jquery-ui-1.8.21.custom.min');
            echo $this->Javascript->link('app-slidePane');
            ?>	

            <div class="modal hide fade" id="loginModal">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times</button>
                    <h3>Acceder al sistema</h3>
                </div>
                <div class="modal-body" style="width:40%; float:left;">
                    <div class="users form">
                        <?php echo $this->Session->flash('auth'); ?>

                        <?php echo $this->Form->create('User', array('action' => 'login')); ?>
                        <fieldset>
                            <?php
                            echo $this->Form->error('username', 'testeo');
                            echo $this->Form->input('username', array('label' => 'Usuario'));
                            echo $this->Form->input('password', array('label' => 'Contrase&ntilde;a'));
                            ?>
                        </fieldset>
                        <?php
                        $options = array('class' => 'btn btn-primary', 'label' => 'Iniciar');
                        echo $this->Form->end($options);
                        ?>
                    </div>
                </div>
                <div class="modal-body" style="width:45%; float:right; margin:auto; text-align:center;">
                    <br/>
                    <?php echo $this->Html->image("candado.png", array('alt' => "Privado")); ?>
                </div>
                <div style="clear:both;"></div>
            </div>

            <div class="modal hide fade" id="readmeModal">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times</button>
                    <h3>Acerca de..</h3>
                </div>
                <div class="modal-body">
                    <div id="readme">
                        <h1>Servicios del corralon los mellizos</h1>
                    </div>
                </div>
                <div style="clear:both;"></div>
            </div>
        </div>
    </body>
</html>
